##
# \file dealer.py
#

# --  Python imports  --
# -- End Python imports --

# --  Pybrain imports  --
# -- End Pybrain imports --

# --  Project imports  --
from actions import Actions
from hand import Hand
from namedcards import Cards
# -- End Project imports --

##
# \class Dealer
# \details This class contains all of the logic for a standard Casino dealer.
class Dealer:

    ##
    # \details Returns the dealers desired action based on their hand.
    # \pre The dealer has been dealt a valid hand.
    # \post none
    # \param none
    # \return The dealers desired action.
    @staticmethod
    def action(hand):
        num_aces = hand.count(Cards.ACE)
        value    = sum(hand)

        while ( (value > Hand.BLACKJACK) and (num_aces > 0) ):
            value    -= 10
            num_aces -= 1

        if ( (value == 17) and (num_aces > 0) ):
            # This is the action for a "Soft-17"
            return Actions.HIT
        else:
            if ( value >= 17 ):
                return Actions.STAND
            else:
                return Actions.HIT

